﻿//作者：       minjie.zhou
// 创建时间：   2012/12/14 23:51:59
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AgileToDo
{
    /// <summary>
    /// UProgressBar.xaml 的交互逻辑
    /// </summary>
    public partial class UProgressBar : UserControl
    {
        public UProgressBar()
        {
            InitializeComponent();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            var sb = this.el.FindResource("sb") as Storyboard;
            var sb2 = this.el2.FindResource("sb2") as Storyboard;
            var sb3 = this.el3.FindResource("sb3") as Storyboard;
            var sb4 = this.el4.FindResource("sb4") as Storyboard;

            var sbr = this.el.FindResource("sbr") as Storyboard;
            var sbr2 = this.el2.FindResource("sbr2") as Storyboard;
            var sbr3 = this.el3.FindResource("sbr3") as Storyboard;
            var sbr4 = this.el4.FindResource("sbr4") as Storyboard;


            sb.Completed += (a,b) =>
                               {
                                   this.el2.Opacity = 1;
                                   sb2.Begin();
                               };
            sb2.Completed += (a, b) =>
            {
                this.el3.Opacity = 1;
                sb3.Begin();
            };
            sb3.Completed += (a, b) =>
            {
                this.el4.Opacity = 1;
                sb4.Begin();
            };

            sb4.Completed += (a, b) =>
            {
                sbr.Begin();
            };
            sbr.Completed += (a, b) =>
            {
                this.el.Opacity = 0;
                sbr2.Begin();
            };
            sbr2.Completed += (a, b) =>
            {
                this.el2.Opacity = 0;
                sbr3.Begin();
            };
            sbr3.Completed += (a, b) =>
            {
                this.el3.Opacity = 0;
                sbr4.Begin();
            };
            sbr4.Completed += (a, b) =>
            {
                this.el4.Opacity = 0;
                this.el.Opacity = 1;
                sb.Begin();
            };


        }

        public void Start()
        {
            var sb = this.el.FindResource("sb") as Storyboard;
            this.el.Opacity = 1;
            sb.Begin();
        }

    }
}
